<template>
  <div class="establish">
    <div v-if="items.length === 0" style="width: 100%;line-height: 3rem;text-align: center;font-size: large;">暂无数据</div>
    <ul v-if="items.length > 0">
      <li v-for="(item, index) in items" :key="index">
        <span @click="startBusiness(item.nameid)" class="establish_apply">进入
          <br/>办理</span>
        <div class="establish_item">
          <div class="establish_item-title">{{item.entName}}</div>
          <div class="establish_item-info">{{item.notNo}}</div>
        </div>
      </li>
    </ul>
    <div class="establish_fix">
      <div>如果非本账号申请的名称需要通过系统校验后可继续办理业务</div>
      <router-link :to="{ name: 'OtherSetupList' }">非本账号申请</router-link>
    </div>
  </div>
</template>

<script>
import MyFooter from '../../components/MyFooter.vue'
import request from '../../utils/request'
export default {
  data() {
    return {
      items: []
    }
  },
  components: {
    MyFooter
  },
  methods: {
    getList() {
      request.get('/interface/apply/cp/setup/queryNameList.do'
        ).then(response => {
          if (response.data.result === 'error') {
            this.$ErrorAlert(response.data.message)
            return null
          }
          // 成功逻辑
          this.items = response.data.data
        })
    },
    startBusiness(nameid) {
      request.get('/interface/apply/cp/setup/startBusiness.do', {
          apprno: nameid,
          regorg: localStorage.getItem('regorg')
      }).then(response => {
        if (response.data.result === 'error') {
          this.$ErrorAlert(response.data.message)
          return null
        }
        // 成功逻辑
        this.gid = response.data.data.gid
        sessionStorage.setItem('gid', response.data.data.gid)
        sessionStorage.setItem('pripid', response.data.data.pripid)
        sessionStorage.setItem('username', response.data.data.username)
        this.$router.push({name: 'ApplyModule'})
      })
    }
  },
  mounted() {
    localStorage.setItem('regorg', this.$route.params.regorg)
    this.getList()
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="scss" scoped>
.establish {
  min-height: 100%;
  padding-bottom: 3rem;
  background: #f3f3f3;
  li {
    margin-bottom: 0.54rem;
    background: #fff;
    padding: 0.54rem;
    overflow: hidden;
  }
  &_apply {
    float: right;
    margin-left: 0.54rem;
    padding: 0.22rem 0.43rem;
    cursor: pointer;
    color: #fff;
    border: 1px solid #00b3ff;
    border-radius: 3px;
    background: #00b3ff;
  }
  &_item {
    &-title {
      color: #00b3ff;
      border-bottom: 1px solid #eaeaea;
      padding-bottom: 0.22rem;
      margin-bottom: 0.14rem;
    }
    &-info {
      font-size: 0.43rem;
      color: #7d7d7d;
    }
  }
  &_fix {
    position: fixed;
    left: 0;
    bottom: 0;
    width: 100%;
    padding: 0.54rem;
    display: flex;
    align-items: center;
    background: #fff;
    font-size: 0.5rem;
    overflow: hidden;
    a {
      margin-left: 0.36rem;
      word-break: keep-all;
      padding: 0 0.5rem;
      height: 1.5rem;
      line-height: 1.5rem;
      font-size: 0.5rem;
      border-radius: 3px;
      background: #fc7742;
      color: #fff;
    }
  }
}
</style>
